/*package com.wsjc.web.controller;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.platform.common.contants.Constants;
import com.platform.common.utils.DateUtil;
import com.platform.common.utils.HelpUtil;
import com.platform.common.utils.MapModel;
import com.platform.common.utils.OSSFile;
import com.platform.common.utils.ParseData;
import com.platform.common.utils.SmsUtil;
import com.platform.common.utils.UUIDUtil;
import com.platform.common.utils.UploadUtil;
import com.platform.entity.AtpBaseData;
import com.platform.entity.Atp_test;
import com.platform.entity.Bd_test;
import com.platform.entity.City;
import com.platform.entity.Disinfected;
import com.platform.entity.Employers;
import com.platform.entity.Hospital;
import com.platform.entity.Province;
import com.platform.entity.Push;
import com.platform.entity.Ssoft;
import com.platform.entity.Sterilization;
import com.platform.entity.Sterilization_device;
import com.platform.entity.User;
import com.platform.entity.Uv_test;
import com.platform.entity.vo.Hostpital_Device_result;
import com.platform.exception.BusinessException;
import com.platform.service.HelpService;
import com.platform.service.PcService;
import com.wsjc.common.core.entity.ApiCommonResultVo;
import com.wsjc.manager.entity.WjHospital;

@Controller
@ResponseBody
@RequestMapping(value = "/Pc/")
public class PcHospitalController {

	private static Log log = LogFactory.getLog("accessRecordLog");

	@Autowired
	private PcService pcService;

	@Autowired
	private HelpService helpService;
	
	

	@InitBinder
	protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
		// 对于需要转换为Date类型的属性，使用DateEditor进行处理
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		CustomDateEditor editor = new CustomDateEditor(df, false);
		binder.registerCustomEditor(Date.class, editor);
	}

	

	*//**
	 * 2.1 Pc 被监测单位信息修改 请求方式 ：POST 参数 ：partID : 单位ID ....... GPSy gps维度坐标
	 * 
	 * @return 0 秘钥不合法 , 1 单位不存在 , 2-9 预留 , 10 修改成功 待审核 2:PartID 3:Key 4:Address
	 *         5:Partstyle 6:Contacts 7:Tel 8:Corporate 9:Certificate
	 *         10:Cernumber 11:Permits 12:PerValidity 13:BusnissRecordno
	 *         14:OrganizationCode 15:Divsion 16:GPSx 17:GPSy
	 *//*
	@RequestMapping(value = "updateHospitalInfo", method = RequestMethod.GET)
	public Map<String, Object> updateHospitalInfo(String PartID, String Key, String Address, int Partstyle,
			String Contacts, String Tel, String Corporate, String Certificate, String Cernumber, String Permits,
			String PerValidity, String BusnissRecordno, String OrganizationCode, String Divsion, String GPSx,
			String GPSy) {
		log.info("PC接口 :2.1 " + DateUtil.getTime());
		// 处理空格
		PartID = PartID.replace(" ", "");
		// 处理PartID 大小写
		Map<String, Object> resultMap = null;
		try {
			PartID = HelpUtil.TreateHospitalID(PartID);
			String city_id = PartID.substring(0, 6).toString();
			String hospital_id = PartID.substring(6).toString();
			Map<String, Object> paramsMap = new HashMap<String, Object>();
			paramsMap.put("hospital_id", hospital_id);
			paramsMap.put("t_hospital", Constants.T_HOSPITAL + city_id);
			System.out.println("Pc 被监测单位信息修改   参数  ：" + paramsMap);
			Hospital hospital = null;
			try {
				hospital = pcService.findHospitalByID(paramsMap);
			} catch (Exception e) {
				System.out.println("没有找到 该表 ：" + e.getMessage());
				resultMap = MapModel.getMapModel("0", "", "系统异常");
				log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
				return resultMap;
			}
			if (null == hospital) {
				resultMap = MapModel.getMapModel("1", "", "单位不存在");
				return resultMap;
			}
			if (!hospital.getHospital_key().equals(Key)) {
				resultMap = MapModel.getMapModel("0", "", "秘钥不合法");
			} else {
				// 字符编码处理
				try {
					if (null != Address) {
						Address = URLDecoder.decode(Address, "GBK");
					}
					if (null != Contacts) {
						Contacts = URLDecoder.decode(Contacts, "GBK");
					}
					if (null != Corporate) {
						Corporate = URLDecoder.decode(Corporate, "GBK");
					}
					if (null != Certificate) {
						Certificate = URLDecoder.decode(Certificate, "GBK");
					}
				} catch (UnsupportedEncodingException e2) {
					System.out.println(" 字符编码处理  异常了 ：" + e2.toString());
				}
				hospital = new Hospital();
				hospital.setTable_hospital(Constants.T_HOSPITAL + city_id);
				hospital.setHospital_id(hospital_id); // 医院ID
				hospital.setAddress(Address); // 地址
				hospital.setIndustry_no(Partstyle); // 单位类型
				hospital.setContacts_name(Contacts); // 单位联系人
				hospital.setTel(Tel); // 单位联系人电话
				hospital.setCorporate_name(Corporate); // 单位法人
				hospital.setCertificate_type(Certificate); // 法人证件类型
				hospital.setCernumber(Cernumber); // 法人证件号码
				hospital.setLegal_permits_number(Permits); // 卫生许可证
				hospital.setPermit_expiry_date(DateUtil.fomatDate(PerValidity)); // 卫生许可证有效期
				hospital.setChartered_number(BusnissRecordno); // 营业执照号
				// hospital.set 组织机构代码
				hospital.setArea_id(Divsion); // 行政区划分
				hospital.setGps_x(GPSx); // x坐标
				hospital.setGps_y(GPSy); // y坐标
				System.out.println(" 获取到的 医院要修改的信息 ：" + hospital);
				boolean flag = false;
				try {
					flag = pcService.updateHospitalInfo(hospital);
				} catch (Exception e) {
					resultMap = MapModel.getMapModel("0", "", "系统异常");
					log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
					return resultMap;
				}
				if (flag) {
					resultMap = MapModel.getMapModel("2", "", "未知错误");
				} else {
					resultMap = MapModel.getMapModel("10", "修改成功，待审核", "");
				}
			}
		} catch (Exception e1) {
			resultMap = MapModel.getMapModel("0", "", "用户名异常");
			log.info("捕获异常：" + DateUtil.getTime() + " " + e1.getMessage());
			return resultMap;
		}
		return resultMap;
	}

	*//**
	 * 2.1 Pc 被监测单位信息修改 请求方式 ：POST 参数 ：partID : 单位ID ....... GPSy gps维度坐标
	 * 
	 * @return 0 秘钥不合法 , 1 单位不存在 , 2-9 预留 , 10 修改成功 待审核 2:PartID 3:Key 4:Address
	 *         5:Partstyle 6:Contacts 7:Tel 8:Corporate 9:Certificate
	 *         10:Cernumber 11:Permits 12:PerValidity 13:BusnissRecordno
	 *         14:OrganizationCode 15:Divsion 16:GPSx 17:GPSy
	 *//*
	@RequestMapping(value = "updateHospitalInfo", method = RequestMethod.GET)
	public Map<String, Object> updateHospitalInfo(String PartID, String Key, String Address, int Partstyle,
			String Contacts, String Tel, String Corporate, String Certificate, String Cernumber, String Permits,
			String PerValidity, String BusnissRecordno, String OrganizationCode, String Divsion, String GPSx,
			String GPSy) {
		
		try {
		logger.info("PC-2.1|被监测单位信息修改 ");
		// 处理空格
		PartID = PartID.replace(" ", "");
		// 处理PartID 大小写
		Map<String, Object> resultMap = null;
			PartID = HelpUtil.TreateHospitalID(PartID);
			String city_id = PartID.substring(0, 6).toString();
			String hospital_id = PartID.substring(6).toString();
			Map<String, Object> paramsMap = new HashMap<String, Object>();
			paramsMap.put("hospital_id", hospital_id);
			paramsMap.put("t_hospital", Constants.T_HOSPITAL + city_id);
			System.out.println("Pc 被监测单位信息修改   参数  ：" + paramsMap);
			Hospital hospital = null;
			try {
				hospital = pcService.findHospitalByID(paramsMap);
			} catch (Exception e) {
				System.out.println("没有找到 该表 ：" + e.getMessage());
				resultMap = MapModel.getMapModel("0", "", "系统异常");
				log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
				return resultMap;
			}
			if (null == hospital) {
				resultMap = MapModel.getMapModel("1", "", "单位不存在");
				return resultMap;
			}
			
			WjHospital wjHospital = pcService.findHospitalByNameAndBussno(paramsMap);

			if (null == wjHospital) {
				logger.warn("PC-1.1|未检索到相关医院 params: PartName ->{}, PartBussno ->{}, Key ->{}", PartName, PartBussno,
						Key);
				return new ApiCommonResultVo(0, "参数错误", null);
			}
			
			if (!hospital.getHospital_key().equals(Key)) {
				resultMap = MapModel.getMapModel("0", "", "秘钥不合法");
			} else {
				// 字符编码处理
				try {
					if (null != Address) {
						Address = URLDecoder.decode(Address, "GBK");
					}
					if (null != Contacts) {
						Contacts = URLDecoder.decode(Contacts, "GBK");
					}
					if (null != Corporate) {
						Corporate = URLDecoder.decode(Corporate, "GBK");
					}
					if (null != Certificate) {
						Certificate = URLDecoder.decode(Certificate, "GBK");
					}
				} catch (UnsupportedEncodingException e2) {
					System.out.println(" 字符编码处理  异常了 ：" + e2.toString());
				}
				hospital = new Hospital();
				hospital.setTable_hospital(Constants.T_HOSPITAL + city_id);
				hospital.setHospital_id(hospital_id); // 医院ID
				hospital.setAddress(Address); // 地址
				hospital.setIndustry_no(Partstyle); // 单位类型
				hospital.setContacts_name(Contacts); // 单位联系人
				hospital.setTel(Tel); // 单位联系人电话
				hospital.setCorporate_name(Corporate); // 单位法人
				hospital.setCertificate_type(Certificate); // 法人证件类型
				hospital.setCernumber(Cernumber); // 法人证件号码
				hospital.setLegal_permits_number(Permits); // 卫生许可证
				hospital.setPermit_expiry_date(DateUtil.fomatDate(PerValidity)); // 卫生许可证有效期
				hospital.setChartered_number(BusnissRecordno); // 营业执照号
				// hospital.set 组织机构代码
				hospital.setArea_id(Divsion); // 行政区划分
				hospital.setGps_x(GPSx); // x坐标
				hospital.setGps_y(GPSy); // y坐标
				System.out.println(" 获取到的 医院要修改的信息 ：" + hospital);
				boolean flag = false;
				try {
					flag = pcService.updateHospitalInfo(hospital);
				} catch (Exception e) {
					resultMap = MapModel.getMapModel("0", "", "系统异常");
					log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
					return resultMap;
				}
				if (flag) {
					resultMap = MapModel.getMapModel("2", "", "未知错误");
				} else {
					resultMap = MapModel.getMapModel("10", "修改成功，待审核", "");
				}
			}
		} catch (Exception e1) {
			resultMap = MapModel.getMapModel("0", "", "用户名异常");
			log.info("捕获异常：" + DateUtil.getTime() + " " + e1.getMessage());
			return resultMap;
		}
		return resultMap;
	}

	*//**
	 * 2.2 Pc 被监测单位信息恢复 请求方式 ：GET 参数 ：PartID : 单位ID , Key 软件秘钥
	 * 
	 * @return 0 不成功 list(2--14) 空 , 1 成功 list(2-14) 给值 2:Address Partstyle
	 *         Contacts Tel Corporate Certificate Cernumber Permits PerValidity
	 *         BusnissRecordno OrganizationCode Divsion GPSx GPSy
	 *//*
	@RequestMapping(value = "restoredHospitalInfo", method = RequestMethod.GET)
	public Map<String, Object> restoredHospitalInfo(String PartID, String Key) {
		log.info("PC接口 :2.2  " + DateUtil.getTime());
		// 处理空格
		PartID = PartID.replace(" ", "");
		// 处理PartID 大小写
		Map<String, Object> resultMap = null;
		try {
			PartID = HelpUtil.TreateHospitalID(PartID);
			String city_id = PartID.substring(0, 6).toString();
			String hospital_id = PartID.substring(6).toString();
			Map<String, Object> paramsMap = new HashMap<String, Object>();
			paramsMap.put("hospital_id", hospital_id);
			paramsMap.put("t_hospital", Constants.T_HOSPITAL + city_id);
			Hospital hospital = null;
			try {
				hospital = pcService.findHospitalByID(paramsMap);
			} catch (Exception e) {
				resultMap = MapModel.getMapModel("0", "", "系统异常");
				log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
				return resultMap;
			}
			if (null == hospital) {
				resultMap = MapModel.getMapModel("0", "", "单位不存在");
				return resultMap;
			}
			if (!hospital.getHospital_key().equals(Key)) {
				resultMap = MapModel.getMapModel("0", "", "秘钥不合法");
			} else {
				resultMap = MapModel.getMapModel("1", hospital, "");
			}
		} catch (Exception e1) {
			resultMap = MapModel.getMapModel("0", "", "用户名异常");
			log.info("捕获异常：" + DateUtil.getTime() + " " + e1.getMessage());
			return resultMap;
		}
		return resultMap;
	}

	
	

	*//**
	 * 3.2 被监测单位查看自己的测试记录 请求方式 ：GET 参数 ：partID : 单位ID , Key 软件秘钥 , TestID 测试号0
	 * 
	 * @return 0 不成功 , 1 有效期过期 , 2 测试号不符权限 , 10 成功 ---> 返回：二进制数据包 +PDF文件 网络路径
	 *//*
	@RequestMapping(value = "downDTB", method = RequestMethod.GET)
	public Map<String, Object> downDTB(String PartID, String Key, String TestID, HttpSession session,
			HttpServletResponse response) {
		log.info("PC接口 :3.2 " + DateUtil.getTime());
		// 处理空格
		PartID = PartID.replace(" ", "");
		Map<String, Object> paramsMap = new HashMap<String, Object>();
		String city_id = "";
		String hospital_id = "";
		// 处理PartID 大小写
		try {
			PartID = HelpUtil.TreateHospitalID(PartID);
			// 验证秘钥
			city_id = PartID.substring(0, 6).toString();
			hospital_id = PartID.substring(6).toString();
		} catch (Exception e1) {
			log.info("捕获异常：" + DateUtil.getTime() + " " + e1.getMessage());
			return MapModel.getMapModel("0", "", "用户名异常");
		}
		paramsMap.put("hospital_id", hospital_id);
		paramsMap.put("t_hospital", Constants.T_HOSPITAL + city_id);
		Hospital hospital = null;
		try {
			hospital = pcService.findHospitalByID(paramsMap);
		} catch (Exception e) {
			log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
			return MapModel.getMapModel("0", "", "正在建设中，请耐心等待！");
		}
		if (null == hospital) {
			return MapModel.getMapModel("0", "", "单位不存在");
		}
		if (!hospital.getHospital_key().equals(Key)) {
			return MapModel.getMapModel("0", "", "秘钥不正确");
		}
		if (null != hospital.getUse_expiry_date()) {
			if (new Date().getTime() > hospital.getUse_expiry_date().getTime()) {
				return MapModel.getMapModel("1", "", "有效期过期");
			}
		}
		// 解析 测试类别
		String dtbType = TestID.substring(0, 3).toString();
		String test_id = TestID;
		paramsMap.put("TestId", test_id);
		int num = 0;
		if (dtbType.equals("00s")) { // 灭菌效果
			paramsMap.put("test_tableName", Constants.T_STERILIZATION + city_id);
			paramsMap.put("id", "s_id");
		} else if (dtbType.equals("0sd")) { // 灭菌设备
			paramsMap.put("test_tableName", Constants.T_STERILIZATION_DEVICE + city_id);
			paramsMap.put("id", "sd_id");
		} else if (dtbType.equals("00d")) { // 消毒
			paramsMap.put("test_tableName", Constants.T_DISINFECTED + city_id);
			paramsMap.put("id", "d_id");
		} else if (dtbType.equals("0uv")) { // 紫外
			paramsMap.put("test_tableName", Constants.T_UV + city_id);
			paramsMap.put("id", "uv_id");
		} else if (dtbType.equals("0db")) { // DB测试
			paramsMap.put("test_tableName", Constants.T_BD_TEST + city_id);
			paramsMap.put("id", "bd_id");
		} else if (dtbType.equals("atp")) { // ATP测试
			paramsMap.put("test_tableName", Constants.T_ATP_TEST + city_id);
			paramsMap.put("id", "atp_id");
		} else {
		}
		num = pcService.CheckDtbNumByID(paramsMap);
		System.out.println("num  的 值 ：" + num);
		if (!(num > 0)) {
			return MapModel.getMapModel("2", "", "测试号不符合权限");
		}
		String ossPath = Constants.UP_OSS_FILEPATH_DTB + test_id + ".dtb";
		String dtbFilePath = session.getServletContext().getRealPath(Constants.UPLOAD_DTB_PATH) + "\\" + test_id
				+ ".dtb";
		*//*************** Oss 下载文件 *****************//*
		try {
			OSSFile.DownFile(ossPath, dtbFilePath);
		} catch (Exception e1) {
			System.out.println(" 下载失败---- ");
			log.info("捕获异常：" + DateUtil.getTime() + " " + e1.getMessage());
		}
		response.setCharacterEncoding("utf-8");
		response.setContentType("multipart/form-data");
		response.setHeader("Content-Disposition", "attachment;fileName=" + test_id + ".dtb");
		byte[] dtb_type = null;
		try {
			InputStream inputStream = new FileInputStream(dtbFilePath);
			OutputStream os = response.getOutputStream();
			dtb_type = new byte[1024 * 2];
			int length;
			while ((length = inputStream.read(dtb_type)) > 0) {
				os.write(dtb_type, 0, length);
			}
			inputStream.close();
		} catch (FileNotFoundException e) {
			UploadUtil.delFile(dtbFilePath);
			log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
		} catch (IOException e) {
			UploadUtil.delFile(dtbFilePath);
			log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
		}
		boolean fal = UploadUtil.delFile(dtbFilePath);
		if (fal) {
			System.out.println("删除成功.........");
		} else {
			System.out.println("删除失败..................");
		}
		return null;
	}


	*//**
	 * 4.1 被监测单位查看自己的测试记录清单 请求方式 ：GET 参数 ：partID : 单位ID , Key 软件秘钥 , Datestart
	 * 检索条件开始时间 （可为空） , Dateover 检索条件结束时间 （可为空） Machinebrand 品牌 （可为空）,Department
	 * 科室（可为空）, Teststyle 测试项目 （可为空） 条件 ：存在两种 或多种为联合检查模式， 如果全部为空 ，则是全部获取
	 * 
	 * @return 0 不成功 list(2-x)空 , 1 成功 list (2-x) Testmess 测试号 + 项目 + 测试时间 + 结果
	 *//*
	@RequestMapping(value = "selectTestResult", method = RequestMethod.GET)
	public Map<String, Object> selectTestResult(String PartID, String Key, String Datestart, String Dateover,
			String Machinebrand, String Department, String Teststyle) {
		log.info("PC接口 :4.1 " + DateUtil.getTime());

		// 字符编码处理
		try {
			if (null != Department) {
				Department = URLDecoder.decode(Department, "GBK");
			}
			if (null != Machinebrand) {
				Machinebrand = URLDecoder.decode(Machinebrand, "GBK");
			}
		} catch (UnsupportedEncodingException e2) {
			log.info("捕获异常：" + DateUtil.getTime() + " " + e2.getMessage());
		}
		// 处理空格
		PartID = PartID.replace(" ", "");
		// 处理PartID 大小写
		// try {
		try {
			PartID = HelpUtil.TreateHospitalID(PartID);
		} catch (Exception e1) {
			log.info("捕获异常：" + DateUtil.getTime() + " " + e1.getMessage());
			return MapModel.getMapModel("0", "", "错误的医院ID");
		}
		// 验证秘钥
		Map<String, Object> paramsMap = new HashMap<String, Object>();
		String city_id = PartID.substring(0, 6).toString();
		String hospital_id = PartID.substring(6).toString();
		paramsMap.put("hospital_id", hospital_id);
		paramsMap.put("t_hospital", Constants.T_HOSPITAL + city_id);
		Hospital hospital = null;
		try {
			hospital = pcService.findHospitalByID(paramsMap);
		} catch (Exception e) {
			log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
			return MapModel.getMapModel("0", "", "正在建设中，请耐心等待！");
		}
		if (null == hospital) {
			return MapModel.getMapModel("0", "", "单位不存在");
		}
		if (!hospital.getHospital_key().equals(Key)) {
			return MapModel.getMapModel("0", "", "秘钥不正确");
		}
		if (null != hospital.getUse_expiry_date()) {
			if (new Date().getTime() > hospital.getUse_expiry_date().getTime()) {
				return MapModel.getMapModel("0", "", "有效期过期");
			}
		}
		// 设置其他参数
		if (null != Datestart && null != Dateover) {
			Datestart = Datestart + " 0:0:0";
			Dateover = Dateover + " 23:59:59";
			paramsMap.put("start_time", DateUtil.fomatDatetime(Datestart));
			paramsMap.put("end_time", DateUtil.fomatDatetime(Dateover));
		}
		paramsMap.put("Machinebrand", Machinebrand);
		paramsMap.put("Department", Department);
		List<TestNotes> list = new ArrayList<TestNotes>();
		if (null != Teststyle && !"".equals(Teststyle)) {
			if (Teststyle.equals("00s")) { // 灭菌效果
				paramsMap.put("test_tableName", Constants.T_STERILIZATION + city_id);
				paramsMap.put("id", "s_id");
			} else if (Teststyle.equals("0sd")) { // 灭菌设备
				paramsMap.put("test_tableName", Constants.T_STERILIZATION_DEVICE + city_id);
				paramsMap.put("id", "sd_id");
			} else if (Teststyle.equals("00d")) { // 消毒
				paramsMap.put("test_tableName", Constants.T_DISINFECTED + city_id);
				paramsMap.put("id", "d_id");
			} else if (Teststyle.equals("0uv")) { // 紫外
				paramsMap.put("test_tableName", Constants.T_UV + city_id);
				paramsMap.put("id", "uv_id");
			} else if (Teststyle.equals("0bd")) { // DB测试
				paramsMap.put("test_tableName", Constants.T_BD_TEST + city_id);
				paramsMap.put("id", "bd_id");
			} else if (Teststyle.equals("atp")) { // ATP测试
				paramsMap.put("test_tableName", Constants.T_ATP_TEST + city_id);
				paramsMap.put("id", "atp_id");
			}
			try {
				list = pcService.findTestNotes(paramsMap);
			} catch (Exception e) {
				log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
				return MapModel.getMapModel("1", list, "");
			}
			for (TestNotes tn : list) {
				tn.setProject(Teststyle);
			}
			return MapModel.getMapModel("1", list, "");
		}
		
		 * 操作 所有的检测结果
		 
		List<TestNotes> lt = new ArrayList<TestNotes>();
		String testName = null;
		String type = null;
		for (int i = 0; i < 6; i++) {
			testName = Constants.type[i];
			if (testName.equals("xd_")) {
				String t_desinfected = Constants.T_DISINFECTED + city_id; // 消毒表
				paramsMap.put("test_tableName", t_desinfected);
				paramsMap.put("id", "d_id");
				type = "00d";
			} else if (testName.equals("mj_")) {
				String t_sterilization = Constants.T_STERILIZATION + city_id; // 灭菌
				paramsMap.put("test_tableName", t_sterilization);
				paramsMap.put("id", "s_id");
				type = "00s";
			} else if (testName.equals("mjsb_")) {
				String t_sterilization_device = Constants.T_STERILIZATION_DEVICE + city_id; // 灭菌设备
				paramsMap.put("test_tableName", t_sterilization_device);
				paramsMap.put("id", "sd_id");
				type = "0sd";
			} else if (testName.equals("zw_")) {
				String t_uv = Constants.T_UV + city_id; // 紫外效果包
				paramsMap.put("test_tableName", t_uv);
				paramsMap.put("id", "uv_id");
				type = "0uv";
			} else if (testName.equals("atp_")) {
				String t_atp_test = Constants.T_ATP_TEST + city_id; // atp测试包
				paramsMap.put("test_tableName", t_atp_test);
				paramsMap.put("id", "atp_id");
				type = "atp";
			} else { // db
				String t_db_test = Constants.T_BD_TEST + city_id; // db测试
				paramsMap.put("test_tableName", t_db_test);
				paramsMap.put("id", "bd_id");
				type = "0db";
			}
			try {
				lt = pcService.findTestNotes(paramsMap);
			} catch (Exception e) {
				log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
				continue;
			}
			for (TestNotes tn : lt) {
				tn.setProject(type);
			}
			list.addAll(lt);
		}
		return MapModel.getMapModel("1", list, "");
	}

	

	*//**
	 * 4.3 额外联系型字段--设备品牌 请求方式 ：GET 参数 ：partID : 单位ID , Key 软件秘钥 , Teststyle 测试项目
	 * （可为空）
	 * 
	 * @return 0 不成功list(2--x) 空 , 1 成功 list(2--x) Machine 设备品牌
	 *//*
	@RequestMapping(value = "selectDeviceBrand", method = RequestMethod.GET)
	public Map<String, Object> selectDeviceBrand(String PartID, String Key, String Teststyle) {

		log.info("PC接口 :4.3 " + DateUtil.getTime());
		// 处理空格
		PartID = PartID.replace(" ", "");
		Map<String, Object> paramsMap = new HashMap<String, Object>();
		String city_id = "";
		String hospital_id = "";
		// 处理PartID 大小写
		try {
			PartID = HelpUtil.TreateHospitalID(PartID);
			// 验证秘钥
			city_id = PartID.substring(0, 6).toString();
			hospital_id = PartID.substring(6).toString();
		} catch (Exception e1) {
			log.info("捕获异常：" + DateUtil.getTime() + " " + e1.getMessage());
			return MapModel.getMapModel("0", "", "用户名异常");
		}
		paramsMap.put("hospital_id", hospital_id);
		paramsMap.put("t_hospital", Constants.T_HOSPITAL + city_id);
		paramsMap.put("other", "device_brand");
		Hospital hospital = null;
		try {
			hospital = pcService.findHospitalByID(paramsMap);
		} catch (Exception e) {
			System.out.println("没有找到 该表 ：" + e.getMessage());
			return MapModel.getMapModel("0", "", "正在建设中，请耐心等待！");
		}
		if (null == hospital) {
			return MapModel.getMapModel("0", "", "单位不存在");
		}
		if (!hospital.getHospital_key().equals(Key)) {
			return MapModel.getMapModel("0", "", "秘钥不正确");
		}
		if (null != hospital.getUse_expiry_date()) {
			if (new Date().getTime() > hospital.getUse_expiry_date().getTime()) {
				return MapModel.getMapModel("0", "", "有效期过期");
			}
		}
		List<String> list = new ArrayList<String>();
		if (null != Teststyle && !"".equals(Teststyle)) {
			if (Teststyle.equals("00s")) { // 灭菌效果
				paramsMap.put("test_tableName", Constants.T_STERILIZATION + city_id);
			} else if (Teststyle.equals("0sd")) { // 灭菌设备
				paramsMap.put("test_tableName", Constants.T_STERILIZATION_DEVICE + city_id);
			} else if (Teststyle.equals("00d")) { // 消毒
				paramsMap.put("test_tableName", Constants.T_DISINFECTED + city_id);
			} else if (Teststyle.equals("0uv")) { // 紫外
				paramsMap.put("test_tableName", Constants.T_UV + city_id);
			} else if (Teststyle.equals("0bd")) { // DB测试
				paramsMap.put("test_tableName", Constants.T_BD_TEST + city_id);
			} else if (Teststyle.equals("atp")) { // ATP测试
				paramsMap.put("test_tableName", Constants.T_ATP_TEST + city_id);
			}
			try {
				list = pcService.findOtherByHospitalID(paramsMap);
			} catch (Exception e) {
				log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
				return MapModel.getMapModel("0", "", "正在建设中，请耐心等待！");
			}
			list = getNewList(list);
			return MapModel.getMapModel("1", list, "");
		}
		
		 * 操作 所有的检测结果
		 
		String testName = null;
		for (int i = 0; i < 6; i++) {
			testName = Constants.type[i];
			if (testName.equals("xd_")) {
				String t_desinfected = Constants.T_DISINFECTED + city_id; // 消毒表
				paramsMap.put("test_tableName", t_desinfected);
			} else if (testName.equals("mj_")) {
				String t_sterilization = Constants.T_STERILIZATION + city_id; // 灭菌
				paramsMap.put("test_tableName", t_sterilization);
			} else if (testName.equals("mjsb_")) {
				String t_sterilization_device = Constants.T_STERILIZATION_DEVICE + city_id; // 灭菌设备
				paramsMap.put("test_tableName", t_sterilization_device);
			} else if (testName.equals("zw_")) {
				String t_uv = Constants.T_UV + city_id; // 紫外效果包
				paramsMap.put("test_tableName", t_uv);
			} else if (testName.equals("atp_")) {
				String t_atp_test = Constants.T_ATP_TEST + city_id; // atp测试包
				paramsMap.put("test_tableName", t_atp_test);
			} else { // db
				String t_db_test = Constants.T_BD_TEST + city_id; // db测试
				paramsMap.put("test_tableName", t_db_test);
			}
			try {
				list.addAll(pcService.findOtherByHospitalID(paramsMap));
			} catch (Exception e) {
				log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
				continue;
			}
		}
		list = getNewList(list);
		return MapModel.getMapModel("1", list, "");
	}

	*//**
	 * 4.4 额外联系型字段的检索--设备型号 请求方式 ：GET 参数 ：partID : 单位ID , Key 软件秘钥 , Teststyle
	 * 测试项目 （可为空）
	 * 
	 * @return 0 不成功list(2--x) 空 , 1 成功 list(2--x) Machine 设备型号
	 *//*
	@RequestMapping(value = "selectDeviceKinds", method = RequestMethod.GET)
	public Map<String, Object> selectDeviceKinds(String PartID, String Key, String Teststyle) {
		log.info("PC接口 :4.4 " + DateUtil.getTime());
		// 处理空格
		PartID = PartID.replace(" ", "");
		// 处理PartID 大小写
		Map<String, Object> paramsMap = new HashMap<String, Object>();
		String city_id = "";
		String hospital_id = "";
		try {
			PartID = HelpUtil.TreateHospitalID(PartID);
			// 验证秘钥
			city_id = PartID.substring(0, 6).toString();
			hospital_id = PartID.substring(6).toString();
		} catch (Exception e1) {
			log.info("捕获异常：" + DateUtil.getTime() + " " + e1.getMessage());
			return MapModel.getMapModel("0", "", "用户名异常");
		}
		paramsMap.put("hospital_id", hospital_id);
		paramsMap.put("t_hospital", Constants.T_HOSPITAL + city_id);
		paramsMap.put("other", "device_kinds");
		Hospital hospital = null;
		try {
			hospital = pcService.findHospitalByID(paramsMap);
		} catch (Exception e) {
			log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
			return MapModel.getMapModel("0", "", "正在建设中，请耐心等待！");
		}
		if (null == hospital) {
			return MapModel.getMapModel("0", "", "单位不存在");
		}
		if (!hospital.getHospital_key().equals(Key)) {
			return MapModel.getMapModel("0", "", "秘钥不正确");
		}
		if (null != hospital.getUse_expiry_date()) {
			if (new Date().getTime() > hospital.getUse_expiry_date().getTime()) {
				return MapModel.getMapModel("0", "", "有效期过期");
			}
		}
		List<String> list = new ArrayList<String>();
		if (null != Teststyle && !"".equals(Teststyle)) {
			if (Teststyle.equals("00s")) { // 灭菌效果
				paramsMap.put("test_tableName", Constants.T_STERILIZATION + city_id);
			} else if (Teststyle.equals("0sd")) { // 灭菌设备
				paramsMap.put("test_tableName", Constants.T_STERILIZATION_DEVICE + city_id);
			} else if (Teststyle.equals("00d")) { // 消毒
				paramsMap.put("test_tableName", Constants.T_DISINFECTED + city_id);
			} else if (Teststyle.equals("0uv")) { // 紫外
				paramsMap.put("test_tableName", Constants.T_UV + city_id);
			} else if (Teststyle.equals("0bd")) { // DB测试
				paramsMap.put("test_tableName", Constants.T_BD_TEST + city_id);
			} else if (Teststyle.equals("atp")) { // ATP测试
				paramsMap.put("test_tableName", Constants.T_ATP_TEST + city_id);
			}
			try {
				list = pcService.findOtherByHospitalID(paramsMap);
			} catch (Exception e) {
				log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
				return MapModel.getMapModel("0", "", "正在建设中，请耐心等待！");
			}
			list = getNewList(list);
			return MapModel.getMapModel("1", list, "");
		}
		
		 * 操作 所有的检测结果
		 
		String testName = null;
		for (int i = 0; i < 6; i++) {
			testName = Constants.type[i];
			if (testName.equals("xd_")) {
				String t_desinfected = Constants.T_DISINFECTED + city_id; // 消毒表
				paramsMap.put("test_tableName", t_desinfected);
			} else if (testName.equals("mj_")) {
				String t_sterilization = Constants.T_STERILIZATION + city_id; // 灭菌
				paramsMap.put("test_tableName", t_sterilization);
			} else if (testName.equals("mjsb_")) {
				String t_sterilization_device = Constants.T_STERILIZATION_DEVICE + city_id; // 灭菌设备
				paramsMap.put("test_tableName", t_sterilization_device);
			} else if (testName.equals("zw_")) {
				String t_uv = Constants.T_UV + city_id; // 紫外效果包
				paramsMap.put("test_tableName", t_uv);
			} else if (testName.equals("atp_")) {
				String t_atp_test = Constants.T_ATP_TEST + city_id; // atp测试包
				paramsMap.put("test_tableName", t_atp_test);
			} else { // db
				String t_db_test = Constants.T_BD_TEST + city_id; // db测试
				paramsMap.put("test_tableName", t_db_test);
			}
			try {
				list.addAll(pcService.findOtherByHospitalID(paramsMap));
			} catch (Exception e) {
				log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
				continue;
			}
		}
		list = getNewList(list);
		return MapModel.getMapModel("1", list, "");
	}

	*//**
	 * 4.5 额外联系型字段的检索--使用科室 请求方式 ：GET 参数 ：partID : 单位ID , Key 软件秘钥 , Teststyle
	 * 测试项目 （可为空）
	 * 
	 * @return 0 不成功list(2--x) 空 , 1 成功 list(2--x) Machine 使用科室
	 *//*
	@RequestMapping(value = "selectUseDepartment", method = RequestMethod.GET)
	public Map<String, Object> selectUseDepartment(String PartID, String Key, String Teststyle) {
		log.info("PC接口 :4.5 " + DateUtil.getTime());
		// 处理空格
		PartID = PartID.replace(" ", "");
		Map<String, Object> paramsMap = new HashMap<String, Object>();
		String city_id = "";
		String hospital_id = "";
		// 处理PartID 大小写
		try {
			PartID = HelpUtil.TreateHospitalID(PartID);
			// 验证秘钥
			city_id = PartID.substring(0, 6).toString();
			hospital_id = PartID.substring(6).toString();
		} catch (Exception e1) {
			log.info("捕获异常：" + DateUtil.getTime() + " " + e1.getMessage());
			return MapModel.getMapModel("0", "", "用户名异常");
		}
		paramsMap.put("hospital_id", hospital_id);
		paramsMap.put("t_hospital", Constants.T_HOSPITAL + city_id);
		paramsMap.put("other", "use_department");
		Hospital hospital = null;
		try {
			hospital = pcService.findHospitalByID(paramsMap);
		} catch (Exception e) {
			log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
			return MapModel.getMapModel("0", "", "正在建设中，请耐心等待！");
		}
		if (null == hospital) {
			return MapModel.getMapModel("0", "", "单位不存在");
		}
		if (!hospital.getHospital_key().equals(Key)) {
			return MapModel.getMapModel("0", "", "秘钥不正确");
		}
		if (null != hospital.getUse_expiry_date()) {
			if (new Date().getTime() > hospital.getUse_expiry_date().getTime()) {
				return MapModel.getMapModel("0", "", "有效期过期");
			}
		}
		List<String> list = new ArrayList<String>();
		if (null != Teststyle && !"".equals(Teststyle)) {
			if (Teststyle.equals("00s")) { // 灭菌效果
				paramsMap.put("test_tableName", Constants.T_STERILIZATION + city_id);
			} else if (Teststyle.equals("0sd")) { // 灭菌设备
				paramsMap.put("test_tableName", Constants.T_STERILIZATION_DEVICE + city_id);
			} else if (Teststyle.equals("00d")) { // 消毒
				paramsMap.put("test_tableName", Constants.T_DISINFECTED + city_id);
			} else if (Teststyle.equals("0uv")) { // 紫外
				paramsMap.put("test_tableName", Constants.T_UV + city_id);
			} else if (Teststyle.equals("0bd")) { // BD测试
				paramsMap.put("test_tableName", Constants.T_BD_TEST + city_id);
			} else if (Teststyle.equals("atp")) { // ATP测试
				paramsMap.put("test_tableName", Constants.T_ATP_TEST + city_id);
			}
			try {
				list = pcService.findOtherByHospitalID(paramsMap);
			} catch (Exception e) {
				log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
				return MapModel.getMapModel("0", "", "正在建设中，请耐心等待！");
			}
			list = getNewList(list);
			return MapModel.getMapModel("1", list, "");
		}
		
		 * 操作 所有的检测结果
		 
		String testName = null;
		for (int i = 0; i < 6; i++) {
			testName = Constants.type[i];
			if (testName.equals("xd_")) {
				String t_desinfected = Constants.T_DISINFECTED + city_id; // 消毒表
				paramsMap.put("test_tableName", t_desinfected);
			} else if (testName.equals("mj_")) {
				String t_sterilization = Constants.T_STERILIZATION + city_id; // 灭菌
				paramsMap.put("test_tableName", t_sterilization);
			} else if (testName.equals("mjsb_")) {
				String t_sterilization_device = Constants.T_STERILIZATION_DEVICE + city_id; // 灭菌设备
				paramsMap.put("test_tableName", t_sterilization_device);
			} else if (testName.equals("zw_")) {
				String t_uv = Constants.T_UV + city_id; // 紫外效果包
				paramsMap.put("test_tableName", t_uv);
			} else if (testName.equals("atp_")) {
				String t_atp_test = Constants.T_ATP_TEST + city_id; // atp测试包
				paramsMap.put("test_tableName", t_atp_test);
			} else { // db
				String t_db_test = Constants.T_BD_TEST + city_id; // db测试
				paramsMap.put("test_tableName", t_db_test);
			}
			try {
				list.addAll(pcService.findOtherByHospitalID(paramsMap));
			} catch (Exception e) {
				log.info("捕获异常：" + DateUtil.getTime() + " " + e.getMessage());
				continue;
			}
		}
		list = getNewList(list);
		return MapModel.getMapModel("1", list, "");
	}

	// 去除重复元素
	public List<String> getNewList(List<String> li) {
		List<String> list = new ArrayList<String>();
		for (int i = 0; i < li.size(); i++) {
			String str = li.get(i); // 获取传入集合对象的每一个元素
			if (!list.contains(str)) { // 查看新集合中是否有指定的元素，如果没有则加入
				list.add(str);
			}
		}
		return list; // 返回集合
	}

	*//**
	 * 获取医院信息 ， 发送短信。添加消息推送。
	 *//*
	public void tools(String hospital_id, String city_id, String testName, Date test_time , String test_id ,String smsInfo ) {
		try {
			String t_hospital = Constants.T_HOSPITAL + city_id;
			Map<String, Object> paramsMap = new HashMap<String, Object>();
			paramsMap.put("t_hospital", t_hospital);
			paramsMap.put("hospital_id", hospital_id);
			Hospital hospital = helpService.findHospitalById(paramsMap);
			// 验证是否过期 ，是否打开推送 ， 不满足条件不推送
			if (null != hospital.getUse_expiry_date()) {
				if (new Date().getTime() <= hospital.getUse_expiry_date().getTime()) {
					if (hospital.getPush_switch().equals(Constants.push_close)) {
						return;
					}
				}
			} else {
				if (hospital.getPush_switch().equals(Constants.push_close)) {
					return;
				}
			}

			*//********* 旧版短信推送 **********//*
			// SingleSendSms app = new SingleSendSms();
			// String content = "不合格数据短信推送“" +
			// Calendar.getInstance().get(Calendar.YEAR) + "年"+ (
			// Calendar.getInstance().get(Calendar.MONTH)+1
			// )+"月"+Calendar.getInstance().get(Calendar.DATE)+"日:"
			// + testName +
			// "灭菌温度（灭菌时间）不符合规范相关条款，本批次物品不得作为已灭菌物品使用，请记录本批次物品的处置方式，查找不合格原因，并记录不合格原因和解决方案”"
			// ;
			
			 * String content = "不合格数据短信推送“" + DateUtil.getChinaDate(test_time)
			 * + ":<" + testName +
			 * "> 灭菌温度（灭菌时间）不符合规范相关条款，本批次物品不得作为已灭菌物品使用，请记录本批次物品的处置方式，查找不合格原因，并记录不合格原因和解决方案”"
			 * ;
			 
			// app.SMS_DIY(hospital.getTel(), content);

			*//****** 新版短信推送 ********//*
			SmsUtil.sendNoPassData(hospital.getTel(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(test_time), smsInfo); // "13998641323" hospital.getTel() getChinaDate() -- > 2017年06月26日 10时52分53秒

			Push push = new Push();
			push.setScope(hospital.getArea_id());
			push.setContent(hospital.getHospital_name() + " : " + testName + " 上传一条未合格的数据！");
			push.setIsread(Constants.noRead);
			push.setTitle(Constants.Title_01);
			push.setType(Constants.type_02); // 推送2
			push.setSpare1(test_id);
			push.setSpare3(hospital.getHospital_name());
			helpService.addPush(push);
			System.out.println(" 未合格数据 推送完成 ----");
		} catch (Exception e) {
			log.info("不合格数据推送，短信发送异常");
		}
	}

	
	
	
	


}
*/